public class ThreadDemo2 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(){
            @Override
            public void run(){
                while(true){
                    System.out.println("hello thread\n");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };//这里不要忘记加分号，毕竟是语句

        t.start();//不要忘记调用start方法

        while(true){
            System.out.println("hello main\n");
            Thread.sleep(1000);
        }
    }
}
